The problem in gas analyzers of this type known in the art is that as the light has to travel a certain distance through ambient gas an error is introduced by variations of the content of the gas under measurement in the ambient gas. The magnitude of this error is dependent on the ambient content, on the distance which the light beam travels in the ambient space and the content of the gas under measurement. In a CO.sub.2 analyzer, for instance, where the measuring light beam travels part of its path in the ambient CO.sub.2 content, the varying ambient CO.sub.2 content introduces an error. This problem is accentuated particularly in CO.sub.2 analyzers for the reason that the absorption of infra-red radiation as a function of CO.sub.2 content is strongly non-linear. The ambient carbon dioxide causes equal attenuation both of the measuring and the reference beam. Since in the case of increasing CO.sub.2 content the absorption caused by it increases at a relatively slower rate, that is, the absorption curve plotted as a function of content becomes less steep at the upper end, even a minor additional absorption causes a major error. This is only minimally corrected by the change in gain which is caused by the attenuation of the reference beam due to the ambient environment.